﻿using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using Encryption;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    [WebMethod]
    public string EncyptCredit(string cardNumber)
    {
        return Security.Encode(cardNumber); ;
    }
    [WebMethod]
    public bool CheckCard(string encodeString)
    {
        try
        {
            string decode = Security.Decode(encodeString);
            BankDSTableAdapters.CardInfoTableAdapter cita = new BankDSTableAdapters.CardInfoTableAdapter();
            BankDS.CardInfoDataTable cidt = cita.GetDataBy(decode);
            if (cidt.Rows.Count > 0 && cidt!=null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        catch (Exception ex)
        {
            return false;
        }
    }

}
